<template>

  <uni-list>
  <uni-list-item v-for="(notice,index) in notices" :key="index"
                 :title="notice.title"
                 :note="notice.createDatetime"
                 :clickable="true"
                 :showBadge="notice.readStatus==1"
                 badge-positon="right"
                 badge-text="1"
                 @click="checkDetailed(notice,index)">
  </uni-list-item>
  </uni-list>
</template>

<script>
import {NoticeService} from "../normalUser/public/Notice/noticeService";
export default {
  name: "NoticeView",
  props:{
    notices:{
      default:[],
      type:Array
    }
  },
  methods:{
    checkDetailed(notice,index){
      let url="/pages/normalUser/public/Notice/view?id="+notice.eid;
      uni.navigateTo({
        url: url
      })
      //请求后台，如果当前数据是未读
      if(notice.readStatus==1){
        this.$emit("read",index)
        this.read(notice.eid)
      }
    },
    read(noticeId){
      let userId=uni.getStorageSync('userInfo').eid;
      NoticeService.readNotice(noticeId,userId)
    }
  }
}
</script>

<style scoped>

</style>